package A.Datos;

import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
//import vista.Formulario;

/**
 *
 *
 */
public class ConexionMantenimiento {

    /**
     * @param args the command line arguments
     */
        static Connection conn = null;
        static ResultSet rs=null;
        static Statement st=null;
        
        static String bd="diBaseDeDatos";
        static String pwd="root";
        static String login="root";
        static String url="jdbc:mysql://localhost:3306/"+bd;
        
        public static Connection Enlace(Connection conn) throws SQLException {
            try {
            try {
                Class.forName("com.mysql.jdbc.Driver").newInstance();
            } catch (InstantiationException ex) {
                Logger.getLogger(ConexionMantenimiento.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                Logger.getLogger(ConexionMantenimiento.class.getName()).log(Level.SEVERE, null, ex);
            }
                
                
                
                conn = DriverManager.getConnection(url,login,pwd);
            } catch (ClassNotFoundException e) {
                System.out.println("clase no encontrada");
            }
            return conn;
        }  
        
        public static Statement sta(Statement st) throws SQLException{
            conn =Enlace(conn);
            st=conn.createStatement();            
            return st;
        }
        
       public static ResultSet rset(ResultSet rs, String table) throws SQLException{
            st=sta(st);
            rs=st.executeQuery("select * from "+table);
            return rs;
        }
     
    public static void main(String[] args) {
        // TODO code application logic here
        
        
       // Formulario formulario=new Formulario();
      //  formulario.setVisible(true);
        
        
    }
}